Supports Method Example (VB)

This example uses the Supports method to display the options supported by a recordset opened with different cursor types. The DisplaySupport procedure is required for this procedure to run.

Public Sub SupportsX()

    Dim aintCursorType(4) As Integer
    Dim rstTitles As ADODB.Recordset
    Dim strCnn As String
    Dim intIndex As Integer

    ' Open connections.
        strCnn = "Provider=sqloledb;" & _
        "Data Source=srv;Initial Catalog=Pubs;User Id=sa;Password=; "

    ' Fill array with CursorType constants.
    aintCursorType(0) = adOpenForwardOnly
    aintCursorType(1) = adOpenKeyset
    aintCursorType(2) = adOpenDynamic
    aintCursorType(3) = adOpenStatic
    
    ' Open recordset using each CursorType and 
    ' optimistic locking. Then call the DisplaySupport 
    ' procedure to display the supported options.
    For intIndex = 0 To 3
        Set rstTitles = New ADODB.Recordset
        rstTitles.CursorType = aintCursorType(intIndex)
        rstTitles.LockType = adLockOptimistic
        rstTitles.Open "Titles", strCnn, , , adCmdTable
        
        Select Case aintCursorType(intIndex)
            Case adOpenForwardOnly
                Debug.Print "ForwardOnly cursor supports:"
            Case adOpenKeyset
                Debug.Print "Keyset cursor supports:"
            Case adOpenDynamic
                Debug.Print "Dynamic cursor supports:"
            Case adOpenStatic
                Debug.Print "Static cursor supports:"
        End Select

        DisplaySupport rstTitles
        rstTitles.Close
    Next intIndex

End Sub

Public Sub DisplaySupport(rstTemp As ADODB.Recordset)

    Dim alngConstants(11) As Long
    Dim booSupports As Boolean
    Dim intIndex As Integer

    ' Fill array with cursor option constants.
    alngConstants(0) = adAddNew
    alngConstants(1) = adApproxPosition
    alngConstants(2) = adBookmark
    alngConstants(3) = adDelete
    alngConstants(4) = adFind
    alngConstants(5) = adHoldRecords
    alngConstants(6) = adMovePrevious
    alngConstants(7) = adNotify
    alngConstants(8) = adResync
    alngConstants(9) = adUpdate
    alngConstants(10) = adUpdateBatch
    
    For intIndex = 0 To 10
        booSupports = _
            rstTemp.Supports(alngConstants(intIndex))
        If booSupports Then
            Select Case alngConstants(intIndex)
                Case adAddNew
                    Debug.Print "   AddNew"
                Case adApproxPosition
                    Debug.Print "   AbsolutePosition and AbsolutePage"
                Case adBookmark
                    Debug.Print "   Bookmark"
                Case adDelete
                    Debug.Print "   Delete"
                Case adFind
                    Debug.Print "   Find"
                Case adHoldRecords
                    Debug.Print "   Holding Records"
                Case adMovePrevious
                    Debug.Print "   MovePrevious and Move"
                Case adNotify
                    Debug.Print "   Notifications"
                Case adResync
                    Debug.Print "   Resyncing data"
                Case adUpdate
                    Debug.Print "   Update"
                Case adUpdateBatch
                    Debug.Print "   batch updating"
            End Select
        End If
    Next intIndex

End Sub